{include file="public/header" /}
<link rel="stylesheet" type="text/css" href="/static/admin/css/layui.css">
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>用户列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">   
                <!--<div  class="col-sm-2" style="width: 100px">
                    <div class="input-group" >  
                        <a href="{:url('add_member')}"><button class="btn btn-outline btn-primary" type="button">添加会员</button></a> 
                    </div>
                </div> -->
                    <form name="admin_list_sea" class="form-search" method="post" action="{:url('index')}">
                        <div class="col-sm-2">
                            <input type="text" id="key" class="form-control" name="key" value="{$val}" placeholder="输入需查询的会员昵称" />
                        </div>

                        <div class="col-sm-2">
                            <input type="text" id="phone" class="form-control" name="phone" value="{$phone}" placeholder="手机号" />
                        </div>

<!--                        <div class="col-sm-2">-->
<!--                            <select class="form-control m-b chosen-select" name="role" id='role'>-->
<!--                                <option value="0">选择角色</option>-->
<!--                                <option value="1" {if condition="$role eq 1"}selected{/if}>陪诊师</option>-->
<!--                                <option value="-1" {if condition="$role eq -1"}selected{/if}>会员</option>-->
<!--                            </select>-->
<!--                        </div>-->
                        <span class="input-group-btn">
                                 <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                        </span>
                    </form>                         
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>
            <div class="col-sm-2">

                <div class="form-group">
                    <label>总计：{$count}</label>
                </div>

            </div>
            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                                <th width="4%">ID</th>
                                <th width="9%">昵称</th>
                                <th width="9%">性别</th>

                                <th width="5%">头像</th>

                                <th width="5%">手机号</th>
                                <th width="10%">授权时间</th>
                                <th width="10%">操作</th>
                            </tr>
                        </thead>
                        <script id="list-template" type="text/html">
                            {{# for(var i=0;i<d.length;i++){  }}
                            <tr class="long-td">
                                <td>{{d[i].id}}</td>
                                <td>{{d[i].nickname}}</td>
                                <td>
                                    {{# if(d[i].sex==1){ }}
                                        男
                                    {{# }else if(d[i].sex==2){ }}
                                        女
                                    {{# }else{ }}
                                        未知
                                    {{# } }}
                                </td>

                                <td>
                                    <img src="{{d[i].headimgurl}}" class="img-circle" style="width:35px;height:35px" onerror="this.src='/static/admin/images/head_default.gif'"/>
                                </td>
                                <td>{{d[i].phone}}</td>
                                <td>{{d[i].last_login}}</td>
                                <td>
                                    <a href="javascript:;" onclick="ShowTag({{d[i].phone}})" class="btn btn-primary btn-outline btn-xs">
                                        <i class="fa fa-user"></i>测评记录</a>
                                </td>
                            </tr>
                            {{# } }}
                        </script>
                        <tbody id="list-content"></tbody>
                    </table>
                    <div id="AjaxPage" style=" text-align: right;"></div>
                    <div id="allpage" style=" text-align: right;"></div>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

<!-- 加载动画 -->
<div class="spiner-example">
    <div class="sk-spinner sk-spinner-three-bounce">
        <div class="sk-bounce1"></div>
        <div class="sk-bounce2"></div>
        <div class="sk-bounce3"></div>
    </div>
</div>

{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/js/layui.js"></script>
<script type="text/javascript">

    function addId(id) {
        var type = 'auto';
        layer.open({
            type: 1
            ,title: '输入模板消息OPENID'
            ,offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
            ,id: 'layerDemo'+type //防止重复弹出
            ,content: '<div style="padding: 20px 100px;"><div class="form-group">\n' +
            '                <input name="openid" type="text" class="form-control" id="tt" placeholder="模板消息OPENID"></div></div>'
            ,btn: '确定'
            ,btnAlign: 'c' //按钮居中
            ,shade: 0 //不显示遮罩
            ,yes: function(){
                var openid = $("#tt").val();
                if(!openid) {
                    layer.msg('请输入模板消息OPENID',{icon:1,time:1500,shade: 0.1,});
                    return;
                }

                $.post('{:url("goods_new_state1")}',{id:id,openid:openid},function(data){
                    if(data.code==1){
                        layer.msg(data.msg,{icon:1,time:1500,shade: 0.1,});
                        layer.closeAll();
                        return false;
                    }else{
                        layer.msg(data.msg,{icon:2,time:1500,shade: 0.1,});
                        return false;
                    }
                });
            }
        });
    }


    //laypage分页
    Ajaxpage();
    function Ajaxpage(curr){
        var key=$('#key').val();
        var phone=$('#phone').val();
        var role=$('#role').val();
        $.getJSON('{:url("Member/index")}', {page: curr || 1,key:key,phone:phone,role:role}, function(data){
            $(".spiner-example").css('display','none'); //数据加载完关闭动画 
            if(data==''){
                $("#list-content").html('<td colspan="20" style="padding-top:10px;padding-bottom:10px;font-size:16px;text-align:center">暂无数据</td>');
            }else{
                var tpl = document.getElementById('list-template').innerHTML;
                laytpl(tpl).render(data, function(html){
                    document.getElementById('list-content').innerHTML = html;
                });
                laypage({
                    cont: $('#AjaxPage'),//容器。值支持id名、原生dom对象，jquery对象,
                    pages:'{$allpage}',//总页数
                    skip: true,//是否开启跳页
                    skin: '#1AB5B7',//分页组件颜色
                    curr: curr || 1,
                    groups: 3,//连续显示分页数
                    jump: function(obj, first){
                        if(!first){
                            Ajaxpage(obj.curr)
                        }
                        $('#allpage').html('第'+ obj.curr +'页，共'+ obj.pages +'页');
                    }
                });
            }
        });
    }

//编辑会员
    function ShowTag(id){
        location.href = '/admin/order/index/phone/'+id+'.html';
    }

    function ShowHealth(id){
        location.href = '/admin/health_tag/index/id/'+id+'.html';
    }

    function goods_new_state(id){

        $.post('{:url("goods_new_state")}',{id:id},function(data){
            if(data.code==1){
                var a='<span class="label label-warning">会员</span>'
                $('#zt2'+id).html(a);
                layer.msg(data.msg,{icon:2,time:1500,shade: 0.1,});
                return false;
            }else{
                var b='<span class="label label-info">店员</span>'
                $('#zt2'+id).html(b);
                layer.msg(data.msg,{icon:1,time:1500,shade: 0.1,});
                return false;
            }
        });
        return false;


        // lunhui.status(id,'{:url("goods_new_state")}');
    }


</script>
</body>
</html>